import request from '@/utils/request'
import hiSetting from '@/hiSetting'
import { dataHelper } from 'hi-ui'
export function login(data) {
  //login/pw-login?username=admin&password=123&pn=eaptpl

  return request({
    //url: '/user/login',
    url: hiSetting.oauth + "/login/pw-login",
    method: 'post',
    data
  })
}


export function getInfo() {
  return request({
    url: hiSetting.oauth + '/sys/user/detail',///login/user/detail
    // method: 'get'
    method: 'post'
  })
  // return request({
  //   //url: '/user/info',
  //   url: hiSetting.oauth + "/login/user/action",
  //   method: 'post',
  //   //params: { token }
  //   data: {
  //     "types": ["org", "info"],
  //   }
  // })

  //let modelFile = "xtgl/dataset/UserInfo.xml";
  // let method = 'post'
  // let extParam = {}
  // return dataHelper.queryHelper.query({}, modelFile, "", { request: request, url: hiSetting.queryUrl, method, pn: hiSetting.projectName, extParam })

}


export function getPermission() {
  return request({
    url: '/user/getpermission',
    method: 'get'
  })
}
export function logout() {
  return request({
    url: hiSetting.oauth + '/login/logout',
    method: 'post'
  })
}

export default {
  //修改密码
  editpw(username, password, newpassword) {
    return request({
      url: hiSetting.oauth + "/login/update-password",
      method: 'post',
      data: { username, password, newpassword }
    })
  },
  remove(userid) {
    return request({
      url: 'user/remove',
      method: 'get',
      params: { userid }
    })
  },
  setUserRole(userid, roleid) {
    return request({
      url: 'user/SetUserRole',
      method: 'post',
      data: { userid, roleid }
    })
  },
  setUserPermissions(userid, funcid) {
    return request({
      url: 'user/setUserPermissions',
      method: 'post',
      data: { userid, funcid }
    })
  },
  getUserPermissions(userid) {
    return request({
      url: 'user/getUserPermissions',
      method: 'post',
      data: { userid }
    })
  },
  //查询用户
  queryUser(param, pageNum, pageSize) {
    return request({
      url: hiSetting.platform + '/platf/xtgn/usergl/query',
      method: 'post',
      data: {
        "pageNum": pageNum,
        "pageSize": pageSize,
        "__body": JSON.stringify(param)
      }
    })
  },
  //保存用户
  saveUser(data) {
    return request({
      url: hiSetting.platform + '/sys/user/reg-easy',
      method: 'post',
      data
    })
  },
  //更新用户
  updateUser(data) {
    return request({
      url: hiSetting.platform + '/sys/user/update-easy',
      method: 'post',
      data
    })
  },
  //删除  ['0000','admin']
  deleteUser(ids) {
    return request({
      url: hiSetting.platform + '/platf/xtgn/usergl/delete-user',
      method: 'post',
      data: ids //{"__body":JSON.stringify(ids)}
    })
  },
  //用户禁用
  disabledUser(data) {
    return request({
      url: hiSetting.platform + '/sys/user/disable',
      method: "post",
      data
    })
  },
  //用户启动
  enableUser(data) {
    return request({
      url: hiSetting.platform + '/sys/user/enable',
      method: "post",
      data
    })
  },
  // 账户余额
  getAccount() {
    return request({
      url: hiSetting.platform + '/interface/accountBalance.gm',
      // url: hiSetting.platform + '/test/groovy/test.gm',
      method: 'post',
      // data: {}
    })
  }
}
